001 /*
002 * Copyright 2004 Niclas Hedhman.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
013 * implied.
014 *
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package net.dpml.transit.monitor;
020
021 import java.net.URL;
022
023 /**
024 * Adapts network events to logging messages.
025 *
026 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
027 * @version 1.0.1
028 */
029 public class NetworkMonitorAdapter extends AbstractAdapter
030 implements NetworkMonitor
031 {
032 // ------------------------------------------------------------------------
033 // constructor
034 // ------------------------------------------------------------------------
035
036 /**
037 * Creation of a new network monitor adapter.
038 * @param adapter the logging adapter
039 */
040 public NetworkMonitorAdapter( Adapter adapter )
041 {
042 super( adapter );
043 }
044
045 // ------------------------------------------------------------------------
046 // NetworkMonitor
047 // ------------------------------------------------------------------------
048
049 /**
050 * Handle the notification of an update in the download status.
051 *
052 * @param resource the name of the remote resource being downloaded.
053 * @param expected the expected number of bytes to be downloaded.
054 * @param count the number of bytes downloaded.
055 */
056 public void notifyUpdate( URL resource, int expected, int count )
057 {
058 getAdapter().notify( resource, expected, count );
059 }
060
061 /**
062 * Handle the notification of the completion of of download process.
063 * @param resource the url of the completed resource
064 */
065 public void notifyCompletion( URL resource )
066 {
067 if( getAdapter().isDebugEnabled() )
068 {
069 getAdapter().debug( "downloaded: " + resource );
070 }
071 }
072 }
073